package com.zjc.utils.convert;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.reflect.TypeToken;

/**
 * 属性复制工具类
 *
 * @author zjc
 * @date 2022-07-1 09:47
 */
public class CopyUtils {

    private static Gson gson = new GsonBuilder()
            .setDateFormat("yyyy-MM-dd HH:mm:ss")
            .create();

    private CopyUtils() {

    }

    public static <T> T deepCopy(Object obj, TypeToken<T> typeToken) {
        String objStr = gson.toJson(obj);
        T t = gson.fromJson(objStr, typeToken.getType());
        return t;
    }
}
